package com.example.tms.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.tms.bean.*;
//import com.example.tms.bean.DateCostInfo;
//import com.example.tms.mapper.DateCostMapper;
import com.example.tms.mapper.DateCostMapper;
import com.example.tms.mapper.WaybillMapper;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.persistence.criteria.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 运营分析
 */
@RestController
public class OperateController {

    private final WaybillMapper waybillMapper;
    private final DateCostMapper dateCostMapper;

    @Autowired
    public OperateController(WaybillMapper waybillMapper ,DateCostMapper dateCostMapper) {
        this.waybillMapper = waybillMapper;
        this.dateCostMapper = dateCostMapper;
    }

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    //车辆费用统计
    @RequestMapping(value = "carcost", method = RequestMethod.GET)
    public ReturnInfo getCarCost(@RequestParam(required = false, defaultValue = "") String cph,
                                 @RequestParam(required = false, defaultValue = "") String qsrq,
                                 @RequestParam(required = false, defaultValue = "") String jsrq) {
        List<WaybillMgmt> result = waybillMapper.findAll((Root<WaybillMgmt> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            if (!cph.equals("")) {
                list.add(criteriaBuilder.like(root.get("cph").as(String.class), "%" + cph + "%"));
            }
            if (!qsrq.equals("")) {
                list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("bzrq").as(String.class), qsrq));
            }
            if (!jsrq.equals("")) {
                list.add(criteriaBuilder.lessThanOrEqualTo(root.get("bzrq").as(String.class), jsrq));
            }
            list.add(criteriaBuilder.equal(root.get("sfcz").as(Boolean.class), true));
            Predicate[] p = new Predicate[list.size()];
            criteriaQuery.where(criteriaBuilder.and(list.toArray(p)));
            return criteriaQuery.getRestriction();
        });
        Map<String, String[]> maps = new HashMap<>();
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(result));
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            String jsyxm = ".";
            String jsysj = ".";
            if (job.containsKey("jsyxm")) {
                jsyxm = job.get("jsyxm").toString();
            }
            if (job.containsKey("jsysj")) {
                jsysj = job.get("jsysj").toString();
            }
            String key = job.get("cph").toString() + "," + jsyxm + "," + jsysj;
            if (!maps.containsKey(key)) {
                String value[] = {job.get("gls").toString(), job.get("llcyje").toString(), job.get("sjcyje").toString(), job.get("glf").toString(), job.get("zcjy").toString(), job.get("xjjy").toString(), job.get("buzhu").toString(),
                        job.get("maidan").toString(), job.get("wxfycn").toString(), job.get("wxfycw").toString(), job.get("wzfk").toString(), job.get("tcf").toString(), job.get("zsf").toString(), job.get("zxf").toString(),
                        job.get("chuanpiao").toString(), job.get("sgcl").toString(), job.get("peijian").toString(), job.get("zcqt").toString(), job.get("srcy").toString(), job.get("huihuo").toString(),
                        job.get("hhbh").toString(), job.get("sryk").toString(), job.get("sryf").toString(), job.get("srqt").toString()};
                maps.put(key, value);
            } else {
                String[] val = maps.get(key);
                val[0] = Add(val[0], job.get("gls").toString());
                val[1] = Add(val[1], job.get("llcyje").toString());
                val[2] = Add(val[2], job.get("sjcyje").toString());
                val[3] = Add(val[3], job.get("glf").toString());
                val[4] = Add(val[4], job.get("zcjy").toString());
                val[5] = Add(val[5], job.get("xjjy").toString());
                val[6] = Add(val[6], job.get("buzhu").toString());
                val[7] = Add(val[7], job.get("maidan").toString());
                val[8] = Add(val[8], job.get("wxfycn").toString());
                val[9] = Add(val[9], job.get("wxfycw").toString());
                val[10] = Add(val[10], job.get("wzfk").toString());
                val[11] = Add(val[11], job.get("tcf").toString());
                val[12] = Add(val[12], job.get("zsf").toString());
                val[13] = Add(val[13], job.get("zxf").toString());
                val[14] = Add(val[14], job.get("chuanpiao").toString());
                val[15] = Add(val[15], job.get("sgcl").toString());
                val[16] = Add(val[16], job.get("peijian").toString());
                val[17] = Add(val[17], job.get("zcqt").toString());
                val[18] = Add(val[18], job.get("srcy").toString());
                val[19] = Add(val[19], job.get("huihuo").toString());
                val[20] = Add(val[20], job.get("hhbh").toString());
                val[21] = Add(val[21], job.get("sryk").toString());
                val[22] = Add(val[22], job.get("sryf").toString());
                val[23] = Add(val[23], job.get("srqt").toString());
                maps.put(key, val);
            }
        }
        List<CostInfo> costInfos = new ArrayList<>();
        for (Map.Entry<String, String[]> entry : maps.entrySet()) {
            String keys[] = entry.getKey().split(",");
            String values[] = entry.getValue();
            costInfos.add(new CostInfo(keys, values));
        }
//        try {
//            creatCarExcel(costInfos);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
        return ReturnInfo.info2(costInfos);
    }

    //线路费用统计
    @RequestMapping(value = "roadcost", method = RequestMethod.GET)
    public ReturnInfo getRoadCost(@RequestParam(required = false, defaultValue = "") String xlmczj,
//                                  @RequestParam(required = false, defaultValue = "") String xlzjm,
                                  @RequestParam(required = false, defaultValue = "") String khjczj,
//                                  @RequestParam(required = false, defaultValue = "") String khzjm,
                                  @RequestParam(required = false, defaultValue = "") String qymczj,
//                                  @RequestParam(required = false, defaultValue = "") String qyzjm,
                                  @RequestParam(required = false, defaultValue = "") String qsrq,
                                  @RequestParam(required = false, defaultValue = "") String jsrq) {
        List<WaybillMgmt> result = waybillMapper.findAll((Root<WaybillMgmt> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) -> {
            Path<Boolean> p1 = root.get("sfcz");
            Predicate predicate = criteriaBuilder.equal(p1,true);
            if(!xlmczj.equals("")){
                Path<String> p2 = root.get("xlmc");
                Path<String> p3 = root.get("xlzjm");
                Predicate predicate1 = criteriaBuilder.or(criteriaBuilder.like(p2,"%"+xlmczj+"%"),criteriaBuilder.like(p3,"%"+xlmczj+"%"));
                predicate = criteriaBuilder.and(predicate,predicate1);
            }
            if(!khjczj.equals("")){
                Path<String> p4 = root.get("khjc");
                Path<String> p5 = root.get("khzjm");
                Predicate predicate2 = criteriaBuilder.or(criteriaBuilder.like(p4,"%"+khjczj+"%"),criteriaBuilder.like(p5,"%"+khjczj+"%"));
                predicate = criteriaBuilder.and(predicate,predicate2);
            }
            if(!qymczj.equals("")){
                Path<String> p6 = root.get("qymc");
                Path<String> p7 = root.get("zjm");
                Predicate predicate3 = criteriaBuilder.or(criteriaBuilder.like(p6,"%"+qymczj+"%"),criteriaBuilder.like(p7,"%"+qymczj+"%"));
                predicate = criteriaBuilder.and(predicate,predicate3);
            }
            if (!qsrq.equals("")) {
                Predicate predicate4 = criteriaBuilder.or(criteriaBuilder.greaterThanOrEqualTo(root.get("bzrq").as(String.class), qsrq));
                predicate = criteriaBuilder.and(predicate,predicate4);
            }
            if (!jsrq.equals("")) {
                Predicate predicate5 = criteriaBuilder.or(criteriaBuilder.lessThanOrEqualTo(root.get("bzrq").as(String.class), jsrq));
                predicate = criteriaBuilder.and(predicate,predicate5);
            }
            criteriaQuery.where(predicate);
            return criteriaQuery.getRestriction();
        });
        Map<String, String[]> maps = new HashMap<>();
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(result));
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            String key = job.get("xlmc").toString();
            if (!maps.containsKey(key)) {
                String value[] = {"0", job.get("llcyje").toString(), job.get("sjcyje").toString(), job.get("glf").toString(), job.get("zcjy").toString(), job.get("xjjy").toString(), job.get("buzhu").toString(),
                        job.get("maidan").toString(), job.get("wxfycn").toString(), job.get("wxfycw").toString(), job.get("wzfk").toString(), job.get("tcf").toString(), job.get("zsf").toString(), job.get("zxf").toString(),
                        job.get("chuanpiao").toString(), job.get("sgcl").toString(), job.get("peijian").toString(), job.get("zcqt").toString(), job.get("srcy").toString(), job.get("huihuo").toString(),
                        job.get("hhbh").toString(), job.get("sryk").toString(), job.get("sryf").toString(), job.get("srqt").toString()};
                maps.put(key, value);
            } else {
                String[] val = maps.get(key);
                val[0] = "0";
                val[1] = Add(val[1], job.get("llcyje").toString());
                val[2] = Add(val[2], job.get("sjcyje").toString());
                val[3] = Add(val[3], job.get("glf").toString());
                val[4] = Add(val[4], job.get("zcjy").toString());
                val[5] = Add(val[5], job.get("xjjy").toString());
                val[6] = Add(val[6], job.get("buzhu").toString());
                val[7] = Add(val[7], job.get("maidan").toString());
                val[8] = Add(val[8], job.get("wxfycn").toString());
                val[9] = Add(val[9], job.get("wxfycw").toString());
                val[10] = Add(val[10], job.get("wzfk").toString());
                val[11] = Add(val[11], job.get("tcf").toString());
                val[12] = Add(val[12], job.get("zsf").toString());
                val[13] = Add(val[13], job.get("zxf").toString());
                val[14] = Add(val[14], job.get("chuanpiao").toString());
                val[15] = Add(val[15], job.get("sgcl").toString());
                val[16] = Add(val[16], job.get("peijian").toString());
                val[17] = Add(val[17], job.get("zcqt").toString());
                val[18] = Add(val[18], job.get("srcy").toString());
                val[19] = Add(val[19], job.get("huihuo").toString());
                val[20] = Add(val[20], job.get("hhbh").toString());
                val[21] = Add(val[21], job.get("sryk").toString());
                val[22] = Add(val[22], job.get("sryf").toString());
                val[23] = Add(val[23], job.get("srqt").toString());
                maps.put(key, val);
            }
        }
        List<CostInfo> costInfos = new ArrayList<>();
        for (Map.Entry<String, String[]> entry : maps.entrySet()) {
            String keys = entry.getKey();
            String values[] = entry.getValue();
            costInfos.add(new CostInfo(keys, values));
        }
//        try {
//            creatRoadExcel(costInfos);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
        return ReturnInfo.info2(costInfos);
    }

    private void creatCarExcel(List<CostInfo> costInfos) throws IOException {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("车辆费用统计");
        HSSFRow row1 = sheet.createRow(0);
//        HSSFCell cell=row1.createCell(0);
        row1.createCell(0).setCellValue("车牌号");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
        row1.createCell(1).setCellValue("驾驶员");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
        row1.createCell(2).setCellValue("驾驶员手机");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
        row1.createCell(3).setCellValue("公里数");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
        row1.createCell(4).setCellValue("理论充油金额");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
        row1.createCell(5).setCellValue("实际充油金额");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
        row1.createCell(6).setCellValue("支出项");
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 6, 20));
        row1.createCell(21).setCellValue("收入项");
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 21, 26));
        row1.createCell(27).setCellValue("利润");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 27, 27));
        HSSFRow row2 = sheet.createRow(1);
        row2.createCell(6).setCellValue("过路费");
        row2.createCell(7).setCellValue("节油");
        row2.createCell(8).setCellValue("现金加油");
        row2.createCell(9).setCellValue("线路补助");
        row2.createCell(10).setCellValue("买单");
        row2.createCell(11).setCellValue("维修费用（厂内）");
        row2.createCell(12).setCellValue("维修费用（厂外）");
        row2.createCell(13).setCellValue("违章罚款");
        row2.createCell(14).setCellValue("停车费");
        row2.createCell(15).setCellValue("住宿费");
        row2.createCell(16).setCellValue("装卸费");
        row2.createCell(17).setCellValue("船票");
        row2.createCell(18).setCellValue("事故处理");
        row2.createCell(19).setCellValue("配件");
        row2.createCell(20).setCellValue("其他支出");
        row2.createCell(21).setCellValue("超油");
        row2.createCell(22).setCellValue("回货");
        row2.createCell(23).setCellValue("回货补回");
        row2.createCell(24).setCellValue("油卡");
        row2.createCell(25).setCellValue("运费");
        row2.createCell(26).setCellValue("其他收入");
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(costInfos));
        int i = 2;
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            HSSFRow row = sheet.createRow(i);
            row.createCell(0).setCellValue(job.get("cph").toString());
            row.createCell(1).setCellValue(job.get("jsyxm").toString());
            row.createCell(2).setCellValue(job.get("jsysj").toString());
            row.createCell(3).setCellValue(job.get("gls").toString());
            row.createCell(4).setCellValue(job.get("llcyje").toString());
            row.createCell(5).setCellValue(job.get("sjcyje").toString());
            row.createCell(6).setCellValue(job.get("glf").toString());
            row.createCell(7).setCellValue(job.get("zcjy").toString());
            row.createCell(8).setCellValue(job.get("xjjy").toString());
            row.createCell(9).setCellValue(job.get("buzhu").toString());
            row.createCell(10).setCellValue(job.get("maidan").toString());
            row.createCell(11).setCellValue(job.get("wxfycn").toString());
            row.createCell(12).setCellValue(job.get("wxfycw").toString());
            row.createCell(13).setCellValue(job.get("wzfk").toString());
            row.createCell(14).setCellValue(job.get("tcf").toString());
            row.createCell(15).setCellValue(job.get("zsf").toString());
            row.createCell(16).setCellValue(job.get("zxf").toString());
            row.createCell(17).setCellValue(job.get("chuanpiao").toString());
            row.createCell(18).setCellValue(job.get("sgcl").toString());
            row.createCell(19).setCellValue(job.get("peijian").toString());
            row.createCell(20).setCellValue(job.get("zcqt").toString());
            row.createCell(21).setCellValue(job.get("srcy").toString());
            row.createCell(22).setCellValue(job.get("huihuo").toString());
            row.createCell(23).setCellValue(job.get("hhbh").toString());
            row.createCell(24).setCellValue(job.get("sryk").toString());
            row.createCell(25).setCellValue(job.get("sryf").toString());
            row.createCell(26).setCellValue(job.get("srqt").toString());
            row.createCell(27).setCellValue(job.get("lirun").toString());
            i++;
        }
        FileOutputStream out = new FileOutputStream("E:/XXX.xls");
        wb.write(out);
        out.close();
    }

    private void creatRoadExcel(List<CostInfo> costInfos) throws IOException {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("线路费用统计");
        HSSFRow row1 = sheet.createRow(0);
        row1.createCell(0).setCellValue("线路名称");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
        row1.createCell(1).setCellValue("理论充油金额");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
        row1.createCell(2).setCellValue("实际充油金额");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
        row1.createCell(3).setCellValue("支出项");
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 3, 17));
        row1.createCell(18).setCellValue("收入项");
        sheet.addMergedRegion(new CellRangeAddress(0, 0, 18, 23));
        row1.createCell(24).setCellValue("利润");
        sheet.addMergedRegion(new CellRangeAddress(0, 1, 24, 24));
        HSSFRow row2 = sheet.createRow(1);
        row2.createCell(3).setCellValue("过路费");
        row2.createCell(4).setCellValue("节油");
        row2.createCell(5).setCellValue("现金加油");
        row2.createCell(6).setCellValue("线路补助");
        row2.createCell(7).setCellValue("买单");
        row2.createCell(8).setCellValue("维修费用（厂内）");
        row2.createCell(9).setCellValue("维修费用（厂外）");
        row2.createCell(10).setCellValue("违章罚款");
        row2.createCell(11).setCellValue("停车费");
        row2.createCell(12).setCellValue("住宿费");
        row2.createCell(13).setCellValue("装卸费");
        row2.createCell(14).setCellValue("船票");
        row2.createCell(15).setCellValue("事故处理");
        row2.createCell(16).setCellValue("配件");
        row2.createCell(17).setCellValue("其他支出");
        row2.createCell(18).setCellValue("超油");
        row2.createCell(19).setCellValue("回货");
        row2.createCell(20).setCellValue("回货补回");
        row2.createCell(21).setCellValue("油卡");
        row2.createCell(22).setCellValue("运费");
        row2.createCell(23).setCellValue("其他收入");
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(costInfos));
        int i = 2;
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            HSSFRow row = sheet.createRow(i);
            row.createCell(0).setCellValue(job.get("xlmc").toString());
            row.createCell(1).setCellValue(job.get("llcyje").toString());
            row.createCell(2).setCellValue(job.get("sjcyje").toString());
            row.createCell(3).setCellValue(job.get("glf").toString());
            row.createCell(4).setCellValue(job.get("zcjy").toString());
            row.createCell(5).setCellValue(job.get("xjjy").toString());
            row.createCell(6).setCellValue(job.get("buzhu").toString());
            row.createCell(7).setCellValue(job.get("maidan").toString());
            row.createCell(8).setCellValue(job.get("wxfycn").toString());
            row.createCell(9).setCellValue(job.get("wxfycw").toString());
            row.createCell(10).setCellValue(job.get("wzfk").toString());
            row.createCell(11).setCellValue(job.get("tcf").toString());
            row.createCell(12).setCellValue(job.get("zsf").toString());
            row.createCell(13).setCellValue(job.get("zxf").toString());
            row.createCell(14).setCellValue(job.get("chuanpiao").toString());
            row.createCell(15).setCellValue(job.get("sgcl").toString());
            row.createCell(16).setCellValue(job.get("peijian").toString());
            row.createCell(17).setCellValue(job.get("zcqt").toString());
            row.createCell(18).setCellValue(job.get("srcy").toString());
            row.createCell(19).setCellValue(job.get("huihuo").toString());
            row.createCell(20).setCellValue(job.get("hhbh").toString());
            row.createCell(21).setCellValue(job.get("sryk").toString());
            row.createCell(22).setCellValue(job.get("sryf").toString());
            row.createCell(23).setCellValue(job.get("srqt").toString());
            row.createCell(24).setCellValue(job.get("lirun").toString());
            i++;
        }
        FileOutputStream out = new FileOutputStream("E:/XXX.xls");
        wb.write(out);
        out.close();
    }

    private static String Add(String a, String b) {
        BigDecimal x = new BigDecimal(a);
        BigDecimal y = new BigDecimal(b);
        return x.add(y).toString();
    }

    //日期费用统计
    @RequestMapping(value = "datecost", method = RequestMethod.GET)
    public ReturnInfo getDateCost(@RequestParam(required = false, defaultValue = "") String qsrq,
                                  @RequestParam(required = false, defaultValue = "") String jsrq) {
        List<DateCostInfo> result = dateCostMapper.findAll((Root<DateCostInfo> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            if (!qsrq.equals("")) {
                list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("bzrq").as(String.class), qsrq));
            }
            if (!jsrq.equals("")) {
                list.add(criteriaBuilder.lessThanOrEqualTo(root.get("bzrq").as(String.class), jsrq));
            }
            list.add(criteriaBuilder.equal(root.get("sfcz").as(Boolean.class), true));
            Predicate[] p = new Predicate[list.size()];
            criteriaQuery.where(criteriaBuilder.and(list.toArray(p)));
            return criteriaQuery.getRestriction();
        });
        Map<String, String[]> maps = new HashMap<>();
        JSONArray ja = JSONArray.parseArray(JSON.toJSONString(result));
        for (Object aJa : ja) {
            JSONObject job = (JSONObject) aJa;
            String key = job.get("bzrq").toString();
            if (!maps.containsKey(key)) {
                String value[] = {"0", job.get("glf").toString(), job.get("zcjy").toString(), job.get("xjjy").toString(), job.get("buzhu").toString(),
                        job.get("maidan").toString(), job.get("wxfycn").toString(), job.get("wxfycw").toString(), job.get("wzfk").toString(), job.get("tcf").toString(), job.get("zsf").toString(), job.get("zxf").toString(),
                        job.get("chuanpiao").toString(),
                        job.get("sgcl").toString(),
                        job.get("peijian").toString(),
                        job.get("zcqt").toString(),
                        job.get("bgszc").toString(),
                        job.get("drjk").toString(),
                        job.get("srcy").toString(),
                        job.get("huihuo").toString(),
                        job.get("hhbh").toString(),  job.get("srqt").toString(),  job.get("bgssr").toString(),  job.get("drqk").toString(),  job.get("drhk").toString(),  job.get("zrye").toString()};
                maps.put(key, value);
            } else {
                String[] val = maps.get(key);
                val[0] = "0";
                val[1] = Add(val[1], job.get("glf").toString());
                val[2] = Add(val[2], job.get("zcjy").toString());
                val[3] = Add(val[3], job.get("xjjy").toString());
                val[4] = Add(val[4], job.get("buzhu").toString());
                val[5] = Add(val[5], job.get("maidan").toString());
                val[6] = Add(val[6], job.get("wxfycn").toString());
                val[7] = Add(val[7], job.get("wxfycw").toString());
                val[8] = Add(val[8], job.get("wzfk").toString());
                val[9] = Add(val[9], job.get("tcf").toString());
                val[10] = Add(val[10], job.get("zsf").toString());
                val[11] = Add(val[11], job.get("zxf").toString());
                val[12] = Add(val[12], job.get("chuanpiao").toString());
                val[13] = Add(val[13], job.get("sgcl").toString());
                val[14] = Add(val[14], job.get("peijian").toString());
                val[15] = Add(val[15], job.get("zcqt").toString());
                val[16] = Add(val[16], job.get("bgszc").toString());
                val[17] = Add(val[17], job.get("drjk").toString());
                val[18] = Add(val[18], job.get("srcy").toString());
                val[19] = Add(val[19], job.get("huihuo").toString());
                val[20] = Add(val[20], job.get("hhbh").toString());
                val[21] = Add(val[21], job.get("srqt").toString());
                val[22] = Add(val[22], job.get("bgssr").toString());
                val[23] = Add(val[23], job.get("drqk").toString());
                val[24] = Add(val[24], job.get("drhk").toString());
                val[25] = Add(val[25], job.get("zrye").toString());
                maps.put(key, val);
            }
        }
        List<DateCost> CostInfos = new ArrayList<>();
        for (Map.Entry<String, String[]> entry : maps.entrySet()) {
            String keys = entry.getKey();
            String values[] = entry.getValue();
            CostInfos.add(new DateCost(keys, values));
        }
//        try {
//            creatRoadExcel(costInfos);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
        return ReturnInfo.info2(CostInfos);
    }
}